#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    int t;
    string s;
    cin >> t;
    while (t--) {
        cin >> s;
        bool ok = (s[0] - '0') + (s[1] - '0') + (s[2] - '0') == (s[3] - '0') + (s[4] - '0') + (s[5] - '0');
        puts(ok ? "yes" : "no");
    }
    return 0;
}